package com.didi.gulimall.search.controller;


import com.didi.gulimall.search.service.ElasticSaveService;
import com.didi.gulimall.search.vo.SearchParam;
import com.didi.gulimall.search.vo.SearchResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 10626
 */
@Controller
@Slf4j
public class SearchController {
    @Autowired
    private ElasticSaveService elasticSaveService;
    @GetMapping("list.html")
    public String listPage(SearchParam param, Model model, HttpServletRequest request){
        param.set_queryString(request.getQueryString());
        SearchResult searchResult = elasticSaveService.listPage(param);
        model.addAttribute("result",searchResult);
        return "index";
    }
}
